package com.example.rk.mapper;

import com.example.rk.entity.Admin;
import com.example.rk.entity.Job;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface AdminMapper {
    @Select("select * from admin where name=#{name}")
    Admin findByName(String name);

    @Insert("insert into admin (name,pwd,phone,type) values(#{name},#{pwd},#{phone},#{type})")
    void create(Admin admin);

    @Select("select * from admin where name=#{name} and pwd=#{pwd}")
    Admin findByNameAndPwd(@Param("name") String name,@Param("pwd") String pwd);

    @Delete("delete from admin where id=#{id}")
    void deleteById(int id);
    @Select("select * from admin where name=#{name} and type=#{type}")
    Job findadd(@Param("name") String name, @Param("type") String type);
    @Select("SELECT * FROM admin where id=#{id}")
    Admin findByID(int id);
    @Update("update admin set name=#{name},pwd=#{pwd},phone=#{phone},type=#{type}  where id=#{id}")
    void doEdit(Admin admin);
    List<Admin> findBySearch(String name, String type);

    int count(String code, String name);

    List<Admin> findBySearchWithPage( String name,String pwd,String phone,String type);
    @Select("SELECT * FROM admin where id=#{id}")
    Admin getAdmin(int id);
    @Update("update admin set imageUrl=#{imageUrl}  where id=#{id}")
    void setImageUrl( @Param("imageUrl") String imageUrl, @Param("id") int id);
}
